home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / CRIBBAGE.PAK / DIALOGS.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  100 lines

  1. //--------------------------------------------------------------------------
  2. // Turbo Cribbage -- Copyright (c) 1995, Borland International
  3. //--------------------------------------------------------------------------
  4. #include <owl/pch.h>
  5. #include "dialogs.h"
  6.  
  7. TQuickPointsDialog::TQuickPointsDialog(TWindow* parent, const char *message,
  8.                                         BOOL aPegging, int aActualPoints):
  9.   TDialog(parent, QUICK_POINTS_DIALOG), msgText(message),
  10.   actualPoints(aActualPoints), pegging(aPegging) {
  11.   msg = new TStatic(this, IDC_QUICK_POINTS_MESSAGE);
  12.   points=0;
  13.   for (int i=15;i<30;i++)
  14.     button[i-15]=new TButton(this, IDC_PUSHBUTTON0 + i);
  15.  }
  16.  
  17. void TQuickPointsDialog::SetupWindow() {
  18.   TDialog::SetupWindow();
  19.   TRect rect;
  20.  
  21.   GetWindowRect(rect);
  22.   msg->SetText(msgText);
  23.  
  24.   if (pegging) {
  25.     rect.left+=200;
  26.     rect.top+=100;
  27.     rect.right=rect.left+200;
  28.     rect.bottom=rect.top+200;
  29.     SetWindowPos(0, rect, SWP_NOZORDER);
  30.     for (int i=15;i<30;i++)
  31.       button[i-15]->ShowWindow(SW_HIDE);
  32.   }
  33.   else {
  34.     rect.left+=5;
  35.     rect.top+=5;
  36.     rect.right=rect.left+200;
  37.     rect.bottom=rect.top+270;
  38.     SetWindowPos(0, rect, SWP_NOZORDER);
  39.   }
  40. }
  41.  
  42. DEFINE_RESPONSE_TABLE1(TCutDeckDialog, TDialog)
  43.   EV_WM_PAINT,
  44.   EV_WM_LBUTTONDOWN,
  45.   EV_COMMAND(IDOK, Ignore),
  46.   EV_COMMAND(IDCANCEL, Ignore),
  47. END_RESPONSE_TABLE;
  48.  
  49. DEFINE_RESPONSE_TABLE1(TShowPointsDialog, TDialog)
  50.   EV_COMMAND(CM_DETAIL, ShowDetail),
  51. END_RESPONSE_TABLE;
  52.  
  53. void TShowPointsDialog::SetupWindow() {
  54.   char temp[50];
  55.   TDialog::SetupWindow();
  56.   switch (mode) {
  57.     case mtMissed:
  58.       wsprintf(temp,"You missed %d %s. Computer takes them.",
  59.                missedPoints, (missedPoints==1)?"point":"points");
  60.       break;
  61.     case mtCrib:
  62.       wsprintf(temp,"Computer counts %d %s in the crib.",
  63.                 points, (points==1)?"point":"points");
  64.       break;
  65.     case mtHand:
  66.       wsprintf(temp,"Computer counts %d %s in its hand.",
  67.                 points, (points==1)?"point":"points");
  68.       break;
  69.     case mtPegging:
  70.       wsprintf(temp,"Computer pegs %d %s",
  71.                 points, (points==1)?"point":"points");
  72.       break;
  73.   }
  74.   msg->SetText(temp);
  75.   if ((mode!=mtMissed) && (!points))
  76.     detailBtn->EnableWindow(false);
  77. }
  78.  
  79. void TShowPointsDialog::ShowDetail() {
  80.   TRect rect;
  81.   int tabs[3];
  82.  
  83.   tabs[0]=0;
  84.   tabs[1]=50;
  85.   tabs[2]=100;
  86.   GetWindowRect(rect);
  87.   rect.bottom+=150;
  88.   SetWindowPos(0, rect, SWP_NOMOVE | SWP_NOZORDER);
  89.   detailBtn->ShowWindow(SW_HIDE);
  90.   ok->SetWindowPos(0, TRect(30, 200, 0, 0), SWP_NOSIZE | SWP_NOZORDER);
  91.   listbox = new TListBox(this, 1, 10, 50, 210, 150);
  92.   listbox->Attr.Style = (listbox->Attr.Style & ~LBS_SORT) | LBS_USETABSTOPS;
  93.   listbox->Create();
  94.   listbox->SetWindowFont(GetWindowFont(), false);
  95.   listbox->SetTabStops(3, tabs);
  96.   for (int i=0;i<detailCount;i++)
  97.     listbox->AddString(detail[i]);
  98. }
  99.  
  100.